package com.fr.plugin.provider.controller;

import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.decision.webservice.utils.WebServiceUtils;
import com.fr.third.springframework.http.MediaType;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.RequestMapping;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
import com.fr.plugin.filter.FRLoginService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/***
 * @desc: 报表权限设置controller
 * @author: zhuosh
 * @date: 2022-05-05
 */
@Controller
@LoginStatusChecker(required = false)
@RequestMapping(value = "/html")
public class AuthHtmlController {


    private FRLoginService frLoginService = new FRLoginService();

    /***
     * 获取权限设置首页
     * @param req
     * @param res
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/idx", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
    @ResponseBody
    public String idx(HttpServletRequest req, HttpServletResponse res)throws Exception{
        String s = "/com/fr/plugin/provider/entrance/auth.html";
        Map<String, Object> param = new HashMap<String, Object>();
        return WebServiceUtils.parseWebPageResourceSafe(s, param);
    }


    /***
     * 返回无权限的查看的页面
     * @param req
     * @param res
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/noauth", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
    @ResponseBody
    public String noauth(HttpServletRequest req, HttpServletResponse res)throws Exception{
        String s = "/com/fr/plugin/provider/entrance/noauth.html";
        Map<String, Object> param = new HashMap<String, Object>();
        return WebServiceUtils.parseWebPageResourceSafe(s, param);
    }



    @RequestMapping(value = "/hello/world")
    @ResponseBody
    public String hello()throws Exception{
        return "Hello World";
    }
}
